package com.example.mk.UI.Msg;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import com.example.mk.R;
import com.example.mk.UI.Navi.NaviBarView;

public class MsgFragment extends Fragment {

    private MsgViewModel msgViewModel;

    public View onCreateView(@NonNull LayoutInflater inflater,
            ViewGroup container, Bundle savedInstanceState) {
        msgViewModel =
                new ViewModelProvider(this).get(MsgViewModel.class);
        View root = inflater.inflate(R.layout.fragment_msg, container, false);
        final TextView textView = root.findViewById(R.id.text_dashboard);
        msgViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
            @Override
            public void onChanged(@Nullable String s) {
                textView.setText(s);
            }
        });

        NaviBarView naviBarView = root.findViewById(R.id.navi_bar_mk);
        naviBarView.setTittle("消息");
        naviBarView.hideBackBtn();

        return root;
    }
}